package org.nicocube.airain.re.proc;

import org.nicocube.airain.domain.client.character.Action;
import org.nicocube.airain.domain.client.character.GameCharacter;
import org.nicocube.airain.domain.client.gamedate.GameDate;
import org.nicocube.airain.domain.client.report.ActionReport;
import org.nicocube.airain.domain.client.report.SleepingActionReport;
import org.nicocube.airain.re.RuleResult;
import org.nicocube.airain.re.utils.Alea;

public class SleepingProcessor extends Processor {

	public SleepingProcessor(GameCharacter gc, Action action, Alea alea) {
		super(gc, action, alea);
	}

	public RuleResult call() throws Exception {
		GameCharacter gc = getGc();
		
		GameDate last = gc.getLastSleepingHour();
		GameDate current = getAction().getGameDate();
		
		if (last.equals(current)) {
			gc.setLastSleepLength(gc.getLastSleepLength()+1);
		}
		
		//TODO find algorithm to recover from being tired
		
		gc.setLastSleepingHour(current);
		
		ActionReport sap = new SleepingActionReport();
		RuleResult result = new RuleResult(sap,gc);
		return result ;
	}

}
